package tarantula.instrumenter;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class PropertyReader {

	public static final String default_file = "./experiments/build.properties";
	
	private static Properties props = null;
	
	private static Properties  loadProperties(String fPath) {
		Properties props = new Properties();
	    try {
            props.load(new FileInputStream(fPath));
            return props;
	     }
	     catch(IOException e)
	     {
	        throw new RuntimeException(e);
	     }
	}
	
	public static void reloadProperty(String fPath) {
		props = loadProperties(fPath);
	}
	
	public static String getProperty(String name) {
		if(props == null) {
			props = loadProperties(default_file);
		}
		return props.getProperty(name);
	}
	
	public static void main(String[] args) {
		reloadProperty(default_file);
		for(Object obj : props.keySet()) {
			System.out.println(obj + " = " + props.getProperty(obj.toString()));
		}
	}
}
